<?php
/*
 * Created on 05.01.2006
 *
 */

/**
 * Creates a hidden field with the doc id for applications working in editor view
 * attributes:
 * dataset
 * field
 * attributes
 */
class cms_imageHandler
{

    var $value;
    var $optiontext;
    var $selected;

    function startElement (& $sender, $attrs)
    {
        if (!$attrs['field'])
        {
            die ("cms:loadimage must have attribute field");
        }
        if (!$attrs['dataset'])
        {
            die ("cms:loadimage must have attribute dataset");
        }
        if (!$attrs['attributes'])
        {
            $attrs['attributes'] = "''";
        }
        preg_match('/^(.*)href/',$attrs['field'],$matches);
        $name = $matches[1];
        $sender->appendCode('$__imgdataset = '.$attrs['dataset'].';'."\n".
                '$__img = $GLOBALS[\'tpl\']->prepareImage($__imgdataset'.
                '['.$attrs['field'].'], '.$attrs['field'].',' .
                ''.$attrs['attributes'].','.$attrs['dataset'].');'."\n".'$out->write($__img['.
                $name.'\'.\'htmltag\']);'."\n");
    }
    
    function endElement (& $sender)
    {
    }

} 

?>